; NLS
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
;
;
; "IF" STATEMENT EQUATES
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
; SPEED/ASM ENTRY POINTS
;
;
;
; NOTE: THE EQUATE OF PUTC MUST
; BE CHANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
PUTC     EQU $7000
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ;FOR USE BY S/A ONLY- SEE DOC.
SAPC     EQU SAGL+3          ; "   "   "  "   "     "   "
HOME     EQU SAPC+3          ;HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
ABS      EQU NOTINSET+3
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
;
;
         JSR INIT
         JMP TST2
;
GETRTN   JSR PRINT
         BYT CR
         BYT CR,"(Press return to continue):",0
         JSR READLN
         JSR HOME
         RTS 
;
;
DIVERROR JSR PRINT
         BYT CR,"DIV",0
;
RTNERROR JSR PRINT
         BYT " returned an error",CR,0
         RTS 
;
;
;
;
TST2     JSR HOME
         JSR PRINT
         BYT "SPEED/ASM test routine, part 2",CR,CR
         BYT "Integer functions.",CR,CR,0
;
;
         JSR LOAD
         ADR 0,I
         JSR LOAD
         ADR 0,J
         JSR PRINT
         BYT "I=",0
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT CR,"J=",0
         JSR PRTINT
         ADR J
         JSR PRINT
         BYT CR
         BYT "Setting I=5",CR,0
         JSR LOAD
         ADR 5,I
         JSR PRINT
         BYT CR
         BYT "Setting J=I",CR,0
         JSR MOVE
         ADR I,J
         JSR PRINT
         BYT CR
         BYT "I=",0
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT CR,"J=",0
         JSR PRTINT
         ADR J
         JSR GETRTN
;
         JSR PRINT
         BYT "Testing ABS:",CR,CR
         BYT "ABS(5)=",0
         JSR LOAD
         ADR 5,I
         JSR ABS
         ADR I
         BVC >0
         JSR PRINT
         BYT CR,"ABS",0
         JSR RTNERROR
         JMP >1
;
^0:
         JSR PRTINT
         ADR I
;
^1:
         JSR PRINT
         BYT CR
         BYT "ABS(-5)=",0
         JSR LOAD
         ADR !-5,I
         JSR ABS
         ADR I
         BVC >0
         JSR PRINT
         BYT CR,"ABS",0
         JSR RTNERROR
         JMP >1
;
^0:
         JSR PRTINT
         ADR I
;
^1:
         JSR PRINT
         BYT CR
         BYT "ABS(0)=",0
         JSR LOAD
         ADR 0,I
         JSR ABS
         ADR I
         BVC >0
         JSR PRINT
         BYT CR,"ABS",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR I
;
^1       JSR PRINT
         BYT CR,"ABS(-32768)=",0
         JSR LOAD
         ADR !-32768,I
         JSR ABS
         ADR I
         BVS >0
         JSR PRINT
         BYT CR
         BYT "ABS did not return an error (uh-oh).",CR,0
         JMP >1
;
^0       JSR PRTINT
         ADR I
         JSR PRINT
         BYT CR,"ABS properly returned an error",CR,0
;
^1       JSR GETRTN
         JSR PRINT
         BYT "Testing NEG:",CR,CR
         BYT "NEG(5)=",0
;
         JSR LOAD
         ADR 5,I
         JSR NEG
         ADR I
         BVC >0
         JSR PRINT
         BYT "NEG",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR I
;
^1       JSR PRINT
         BYT CR,"NEG(-5)=",0
         JSR LOAD
         ADR !-5,I
         JSR NEG
         ADR I
         BVC >0
         JSR PRINT
         BYT CR,"NEG",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR I
;
^1       JSR PRINT
         BYT CR,"NEG(0)=",0
         JSR LOAD
         ADR 0,I
         JSR NEG
         ADR I
         BVC >0
         JSR PRINT
         BYT CR,"NEG",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR I
^1       JSR PRINT
         BYT CR,"NEG(-32768)=",0
         JSR LOAD
         ADR !-32768,I
         JSR NEG
         ADR I
         BVC >0
         JSR PRTINT
         ADR I
         JSR PRINT
         BYT CR,"NEG properly returned an error code",CR,0
         JMP >1
;
^0       JSR PRTINT
         ADR I
         JSR PRINT
         BYT CR,"NEG did not return an error (uh-oh)",CR,0
;
^1       JSR GETRTN
;
;
         JSR PRINT
         BYT "Testing the MUL function:",CR,CR
         BYT "5*25=",0
         JSR LOAD
         ADR 5,I
         JSR LOAD
         ADR 25,J
         JSR MUL
         ADR I,J,K
         BVC >0
;
         JSR PRINT
         BYT CR,"MUL",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"(-5)*(-25)=",0
         JSR NEG
         ADR I
         JSR NEG
         ADR J
         JSR MUL
         ADR I,J,K
         BVC >0
         JSR PRINT
         BYT CR
         BYT "MUL"
         BYT 0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"(-5)*25=",0
         JSR NEG
         ADR J
         JSR MUL
         ADR I,J,K
         BVC >0
         JSR PRINT
         BYT CR,"MUL",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"5*(-25)=",0
         JSR NEG
         ADR I
         JSR NEG
         ADR J
         JSR MUL
         ADR I,J,K
         BVC >0
         JSR PRINT
         BYT CR,"MUL",0
         JSR RTNERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"32000*4=",0
         JSR LOAD
         ADR 32000,I
         JSR LOAD
         ADR 4,J
         JSR MUL
         ADR I,J,K
         BVS >0
         JSR PRINT
         BYT CR,"MUL did not return an error (Uh-oh).",CR,0
         JMP >0
;
^0       JSR PRINT
         BYT CR,"MUL properly returned an error",CR,0
;
^1       JSR PRINT
         BYT CR,"(-32000)*4=",0
         JSR NEG
         ADR I
         JSR MUL
         ADR I,J,K
         BVS >0
         JSR PRINT
         BYT CR,"MUL did not return an error (uh-oh)",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT CR,"MUL properly returned an error",CR,0
;
^1       JSR GETRTN
;
         JSR PRINT
         BYT "Testing the DIV function:",CR,CR
;
         BYT "25/5=",0
         JSR LOAD
         ADR 25,I
         JSR LOAD
         ADR 5,J
         JSR DIV
         ADR I,J,K
         BVC >0
         JSR DIVERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"(-25)/5=",0
         JSR NEG
         ADR I
         JSR DIV
         ADR I,J,K
         BVC >0
         JSR DIVERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"(-25)/(-5)=",0
         JSR NEG
         ADR J
         JSR DIV
         ADR I,J,K
         BVC >0
         JSR DIVERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"5/25=",0
         JSR LOAD
         ADR 5,I
         JSR LOAD
         ADR 25,J
         JSR DIV
         ADR I,J,K
         BVC >0
         JSR DIVERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"5/0=",0
         JSR LOAD
         ADR 0,J
         JSR DIV
         ADR I,J,K
         BVS >0
         JSR PRINT
         BYT CR,"DIV did not return an error (uh-oh)",CR,0
         JMP >0
;
^0       JSR PRINT
         BYT CR,"DIV properly returned an error code",CR,0
;
^1       JSR GETRTN
;
;
         JSR PRINT
         BYT CR,"Testing the MOD function:",CR,CR
;
         BYT "25 MOD 5 =",0
;
         JSR LOAD
         ADR 25,I
         JSR LOAD
         ADR 5,J
         JSR MOD
         ADR I,J,K
         BVC >0
         JSR MODERROR
         JMP >1
;
MODERROR JSR PRINT
         BYT CR,"MOD"
         BYT 0
         JMP RTNERROR
;
^0       JSR PRTINT
         ADR K
;
^1       JSR PRINT
         BYT CR,"25 MOD 7 =",0
         JSR LOAD
         ADR 7,J
         JSR MOD
         ADR I,J,K
         BVC >0
         JSR MODERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
;
^1       JSR PRINT
         BYT CR,"7 MOD 25 =",0
         JSR MOD
         ADR J,I,K
         BVC >0
         JSR MODERROR
         JMP >1
;
^0       JSR PRTINT
         ADR K
;
;
^1       JSR PRINT
         BYT CR,"7 MOD 0 =",0
         JSR LOAD
         ADR 0,I
         JSR MOD
         ADR J,I,K
         BVS >0
         JSR PRTINT
         ADR K
         JSR PRINT
         BYT CR,"MOD did not return an error (uh-oh)",CR,0
         JMP >1
;
^0       JSR PRINT
         BYT CR,"MOD properly returned an error.",CR,0
;
^1       JSR GETRTN
         JSR PRINT
         BYT "Testing the RND function:",CR,CR
         BYT 0
;
         JSR FOR0
         ADR I,1,10
;
         JSR RND
         ADR J
         JSR PRINT
         BYT CR,"RND=",0
         JSR PRTINT
         ADR J
;
         JSR NEXT
;
         JSR GETRTN
;
;
         JSR PRINT
         BYT CR,"Testing the RDINT routine:",CR,CR
         BYT "Enter 125:",0
         JSR READLN
         JSR RDINT
         ADR I
         BVC >0
         JSR RDERROR
         JMP >1
;
^0       JSR IFI0
         ADR I,EQ,125
         BTR >1
         JSR RDERROR
;
^1       JSR PRINT
         BYT CR,"Enter ""+125"":",0
         JSR READLN
         JSR RDINT
         ADR I
         BVS >0
         JSR PRINT
         BYT CR,"RDINT did not return an error (uh-oh)",CR,0
         JMP >1
;
^0       CMP #0
         BEQ >1
         JSR RDERROR
;
^1       JSR PRINT
         BYT CR,"Enter ""125A"":",0
         JSR READLN
         JSR RDINT
         ADR I
         BVS >0
         JSR PRINT
         BYT CR,"RDINT did not return an error (uh-oh)",CR,0
         JMP >1
;
^0       CMP #1
         BEQ >1
         JSR RDERROR
;
^1       JSR PRINT
         BYT CR,"Enter 99999:",0
         JSR READLN
         JSR RDINT
         ADR I
         BVS >0
         JSR PRINT
         BYT CR,"RDINT did not return an error (uh-oh)",CR,0
         JMP >1
;
^0       CMP #$80
         BEQ >1
;
         JSR RDERROR
;
^1       JSR PRINT
         BYT CR,"Enter -125:",0
         JSR READLN
         JSR RDINT
         ADR I
         BVC >0
         JSR RDERROR
         JMP >1
;
^0       JSR IFI0
         ADR I,EQ,!-125
         BTR >1
         JSR RDERROR
;
^1       JSR GETRTN
         JSR PRINT
         BYT CR,CR,CR,"That's all folks...",CR,0
         JMP ENDPGM
;
;
RDERROR  JSR PRINT
         BYT CR,"Either you entered something",CR
         BYT "incorrectly, or RDINT isn't working",CR
         BYT "properly.",CR,0
         RTS 
;
ENDPGM   RTS 
;
;
I        ADR 0
J        ADR 0
K        ADR 0
         END